//package com.chetubao.controller;
//
//import com.chetubao.entity.UserInfo;
//import com.chetubao.service.UserInfoService;
//import com.chetubao.util.TokenUtil;
//import com.chetubao.util.WebUtil;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.solar.bean.JsonResult;
//import org.solar.bean.Token;
//import org.solar.cache.Cache;
//import org.solar.coder.Md5Util;
//import org.solar.util.Assert;
//import org.springframework.stereotype.Controller;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.ResponseBody;
//
//import javax.annotation.Resource;
//import javax.servlet.http.HttpServletRequest;
//
//@Controller
//public class LoginController {
//    private static final Logger logger = LoggerFactory.getLogger(LoginController.class);
//
//    @Resource
//    private UserInfoService userInfoService;
//    @RequestMapping("isLogin")
//    @ResponseBody
//    public JsonResult isLogin(HttpServletRequest hreq) {
//        Token token= TokenUtil.getToken(hreq);
//
//        if (token !=null) {
//            return JsonResult.success(userInfoService.getById(token.getId()));
//        }
//
//        return JsonResult.error("未登录!");
//    }
//
//    @RequestMapping("login")
//    @ResponseBody
//    public JsonResult login( HttpServletRequest request,String account, String password) throws Exception {
//        Assert.notNull(account,"账号");
//        Assert.notNull(password,"密码");
//        UserInfo accountBean=userInfoService.selectOneByWhere("loginName",account,"password", Md5Util.getMd5Hex(password));
//        if (accountBean==null){
//            return JsonResult.error("账号或密码错误!");
//        }
//        Token token=new Token();
//        token.setId(accountBean.getId());
//        token.setType(accountBean.getState());
//        //秒单位
//        token.setExpireTime(60 * 60 * 12);
//        token.setIp(WebUtil.getIpAddr(request));
//        return new JsonResult(200,TokenUtil.toString(token),accountBean);
//    }
//
//
//    @RequestMapping("loginOut")
//    @ResponseBody
//    public JsonResult loginOut(HttpServletRequest hreq) throws Exception {
//
//        return JsonResult.success();
//    }
//}
